package com.wanmao.test;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.TextView;

import com.wanmao.test.bean.GZJLBean;
import com.wanmao.test.service.GZJLService;



public class FaultDetailsActivity extends BaseActivity {
    private String TAG = "故障记录详情";
    private String OBJ_ID,ZYLX;
    private GZJLService gzjlService = new GZJLService(this);
    private GZJLBean gzjlBean;
    private TextView BDZMCtv, GZIDtv, GZXLtv, JZZYtv, DYDJtv,FSSJtv,GZLXtv,SFTZtv,SFTYtv,DZJTtv,GZQKtv;
    private String  OBJ_ID_Show, BDZMC, GZXLMC, DYDJ, GZFSSJ, GZLX, SFTZ,SFTY,GZJT,GZQK;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fault_details);
        Intent intent =getIntent();
        OBJ_ID=intent.getStringExtra("OBJ_ID");
        ZYLX=intent.getStringExtra("ZYLX");
        if(ZYLX==null){
            ZYLX="";
        }

        initData();
        initView();
    }

    private void initData() {
        gzjlBean = gzjlService.findByOBJID(OBJ_ID);
        if (gzjlBean != null) {
            Log.e(TAG, gzjlBean.toString());
            OBJ_ID = gzjlBean.getOBJ_ID();
            BDZMC = gzjlBean.getBDZMC();
            OBJ_ID_Show = OBJ_ID.substring(0,36);
            GZXLMC = gzjlBean.getGZXLMC();
            DYDJ = gzjlBean.getDYDJ();
            GZFSSJ = gzjlBean.getGZFSSJ();
            GZLX = gzjlBean.getGZLX();
            SFTZ = gzjlBean.getSFTZ();
            SFTY = gzjlBean.getSFTY();
            if(SFTZ.equals("1")){
                SFTZ="是";
            }else {
                SFTZ="否";
            }
            if(SFTY.equals("1")){
                SFTY="是";
            }else {
                SFTY="否";
            }
            GZJT = gzjlBean.getGZJT();
            GZQK = gzjlBean.getGZQK();
        }

    }

    private void initView() {
        BDZMCtv= (TextView) findViewById(R.id.BDZMCtv);
        GZIDtv= (TextView) findViewById(R.id.GZIDtv);
        GZXLtv= (TextView) findViewById(R.id.GZXLtv);
        JZZYtv= (TextView) findViewById(R.id.JZZYtv);
        DYDJtv= (TextView) findViewById(R.id.DYDJtv);
        FSSJtv= (TextView) findViewById(R.id.FSSJtv);
        GZLXtv= (TextView) findViewById(R.id.GZLXtv);
        SFTZtv= (TextView) findViewById(R.id.SFTZtv);
        SFTYtv= (TextView) findViewById(R.id.SFTYtv);
        DZJTtv= (TextView) findViewById(R.id.DZJTtv);
        GZQKtv= (TextView) findViewById(R.id.GZQKtv);

        BDZMCtv.setText(BDZMC);
        GZIDtv.setText("故障ID:"+OBJ_ID_Show);
        GZXLtv.setText(GZXLMC);
        JZZYtv.setText(ZYLX);
        DYDJtv.setText(DYDJ);
        FSSJtv.setText(GZFSSJ);
        GZLXtv.setText(GZLX);
        SFTZtv.setText(SFTZ);
        SFTYtv.setText(SFTY);
        DZJTtv.setText(GZJT);
        GZQKtv.setText(GZQK);

    }
}
